package com.suray.system.run.task;

import com.suray.commin.core.utils.SpringContextHolder;
import com.suray.wcs.service.enums.TaskType;
import com.suray.wcs.service.system.service.impl.TaskDBServiceImpl;

public class TaskInformation {
    private TaskDBServiceImpl taskDBService = SpringContextHolder.getBean(TaskDBServiceImpl.class);

    /**
     * 任务类型
     */
    private TaskType taskType;

    /**
     * 完成的任务
     */
    private int finishTaskNum;

    /**
     * 进行中的任务
     */
    private int execingTaskNum;

    /**
     * 取消的任务
     */
    private int cancelTaskNum;

    /**
     * 故障的任务
     */
    private int errorTaskNum;

    /**
     * 未执行的任务
     */
    private int waitForExecTaskNum;

    public TaskInformation(TaskType taskType) {
        this.taskType = taskType;
        count();
    }

    public void count() {
        finishTaskNum = taskDBService.countFinishTask(taskType);
        execingTaskNum = taskDBService.countExecTask(taskType);
        cancelTaskNum = taskDBService.countCancelTask(taskType);
        errorTaskNum = taskDBService.countErrorTask(taskType);
        waitForExecTaskNum = taskDBService.countWaitForExecTask(taskType);
    }

    public TaskType getTaskType() {
        return taskType;
    }

    public int getFinishTaskNum() {
        return finishTaskNum;
    }

    public int getExecingTaskNum() {
        return execingTaskNum;
    }

    public int getCancelTaskNum() {
        return cancelTaskNum;
    }

    public int getErrorTaskNum() {
        return errorTaskNum;
    }

    public int getWaitForExecTaskNum() {
        return waitForExecTaskNum;
    }
}
